package com.cl.blog.web.client.review;

import com.cl.blog.annotation.Login;
import com.cl.blog.common.Result;
import com.cl.blog.entity.BContent;
import com.cl.blog.entity.BContentReview;
import com.cl.blog.service.BContentReviewService;
import com.cl.blog.vo.ContentReviewVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @Author 付
 * @Date 2024-04-03 16:25
 * @Version 1.0
 * @description
 * @since 1.0
 */

@RestController
@RequestMapping("/user/review")
public class ContentReviewController {
	@Autowired
	BContentReviewService bContentReviewService;

	// 获取所有的评论(包含了文章和问答社区的评论)
	@GetMapping("/list")
	@Login
	public Result list(HttpServletRequest request) {
		Object list = bContentReviewService.selectAll(request);
		return Result.success(list);
	}

	/**
	 * 查询文章的评论列表
	 *
	 * @param contentId 文章id
	 * @return 评论列表
	 */
	@GetMapping("/content")
	@Login
	public Result getList(Integer contentId) {
		Object obj = bContentReviewService.selectContentReview(contentId);

		return Result.success(obj);
	}

	@PostMapping("/add")
	@Login
	public Result insertReview(@RequestBody ContentReviewVo reviewVo, HttpServletRequest request) {
		boolean b = bContentReviewService.insertReview(reviewVo, request);
		return Result.success();
	}
}
